/**
 * 
 */
package com.sci.web.action.datareportseason.enterprisenew;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.Enterprise_New;
import com.sci.web.dao.DataReportM_InnovateBaseDao;

/**
 * @author  BaiFuyou
 * @date: Nov 10, 2011 1:48:58 PM
 */
public class AddNewEnterprise_NewDataAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8998120574163229142L;
	@Resource
	private DataReportM_InnovateBaseDao dataReportM_InnovateBaseDao;
	private int userId;
	private int type;
	private String year;
	private double new_income;
	private double new_all_income;
	private double new_ratio;
	/**
	 * @return the userId
	 */
	public int getUserId() {
		return userId;
	}
	/**
	 * @param userId the userId to set
	 */
	public void setUserId(int userId) {
		this.userId = userId;
	}
	/**
	 * @return the type
	 */
	public int getType() {
		return type;
	}
	/**
	 * @param type the type to set
	 */
	public void setType(int type) {
		this.type = type;
	}
	/**
	 * @return the year
	 */
	public String getYear() {
		return year;
	}
	/**
	 * @param year the year to set
	 */
	public void setYear(String year) {
		this.year = year;
	}
	/**
	 * @return the new_income
	 */
	public double getNew_income() {
		return new_income;
	}
	/**
	 * @param new_income the new_income to set
	 */
	public void setNew_income(double new_income) {
		this.new_income = new_income;
	}
	/**
	 * @return the new_all_income
	 */
	public double getNew_all_income() {
		return new_all_income;
	}
	/**
	 * @param new_all_income the new_all_income to set
	 */
	public void setNew_all_income(double new_all_income) {
		this.new_all_income = new_all_income;
	}
	/**
	 * @return the new_ratio
	 */
	public double getNew_ratio() {
		return new_ratio;
	}
	/**
	 * @param new_ratio the new_ratio to set
	 */
	public void setNew_ratio(double new_ratio) {
		this.new_ratio = new_ratio;
	}
	
	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("new_year", year);
		map.put("new_type", type);
		map.put("uid", userId);
		if(dataReportM_InnovateBaseDao.isEnterprise_NewExistBeforeInsert(map)){
			super.outPrint("already");
			return "json";
		}
		Enterprise_New en = new Enterprise_New();
		en.setEditable(1);
		en.setEnterprise_id(dataReportM_InnovateBaseDao.getEnterpriseBaseId(userId));
		en.setNew_all_income(new_all_income);
		en.setNew_check_pass(3);
//		en.setNew_id(new_id)
		en.setNew_is_new(0);
		en.setNew_ratio(new_ratio);
		en.setNew_type(type);
		en.setNew_year(year);
		en.setNew_income(new_income);
		if(dataReportM_InnovateBaseDao.insertEnterprise_NewData(en)){
			super.outPrint("ok");
		}else{
			super.outPrint("fail");
		}
		return "json";
	}

}
